#include "SRendererDX9.h"

#include "CViewD3D9.h"
#include "CImage.h"

//----------------------------------------------
SRendererDX9::SRendererDX9() :
m_pD3d(NULL),
m_pActiveView(NULL)
{
	m_pD3d = Direct3DCreate9(D3D_SDK_VERSION);
	m_pD3d->GetDeviceCaps( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &m_oCaps );
	m_pViews.reserve(m_oCaps.NumberOfAdaptersInGroup);
}

//----------------------------------------------
SRendererDX9::~SRendererDX9()
{
	if (m_pD3d != NULL)
		m_pD3d->Release();
}

//----------------------------------------------
bool SRendererDX9::loadTexture (CImage& oImage)
{
	bool bOk = true;
	for (vector<CViewD3D9*>::iterator it = m_pViews.begin(); it != m_pViews.end(); it++)
	{
		CViewD3D9* pView = *it;
		if (!pView->loadTexture(oImage))
			bOk = false;
	}
	return bOk;
}

//----------------------------------------------
void SRendererDX9::unloadTexture (CImage& oImage)
{
	for (vector<CViewD3D9*>::iterator it = m_pViews.begin(); it != m_pViews.end(); it++)
	{
		CViewD3D9* pView = *it;
		pView->unloadTexture(oImage);
	}
}
